import { ref, computed } from '@vue/composition-api'


export default function toggleHook(defaultValue, reverseValue){

    const state = ref(defaultValue)
    const reverseValueOrigin = computed(() => reverseValue === undefined ? !defaultValue : reverseValue )
    const toggle = value => state.value = value !== undefined ? value : state.value === defaultValue ? reverseValueOrigin.value : defaultValue
    const setLeft = () => state.value = defaultValue
    const setRight = () => state.value = reverseValueOrigin.value
    
    
    return {
        state,
        toggle,
        setLeft,
        setRight
    }
}
